Skip to content

Add config flow for Hue#12830

Merged
balloob merged 11 commits intodevfrom
hue
Mar 4, 2018
Merged

Add config flow for Hue#12830
balloob merged 11 commits intodevfrom
hue

Conversation

@balloob
Copy link
Copy Markdown
Member

@balloob balloob commented Mar 2, 2018

Description:

This PR adds a config flow for Philips Hue to allow users to configure it via the UI.

The library that we use to control Philips Hue lights is bad (and unmaintained). It forces everything via a file and will even do auto lookups. It will also not correctly handle if an auth token has been revoked.

Instead of trying to hack around the shortcomings of Phue, I wrote aiohue. It supports registering, fetching config and reading/controlling lights and groups. Oh, and it's async 👍 The goal will be to eventually migrate all of Hue to this lib. For now it's only used to handle authentication in the config flow.

hue-flow

A reminder that the config entry config for Hue will live besides the existing config.

To do:

  • add tests (all config flows need full test coverage)

Out of scope for this PR:

  • Have discovery trigger the config flow instead of configurator

Requires home-assistant/frontend#960 for frontend to work.

Example entry for configuration.yaml (if applicable):

config:
  config_entries: 1

(then navigate to config panel)

Checklist:

  • The code change is tested and works locally.

If the code does not interact with devices:

  • Local tests with tox run successfully. Your PR cannot be merged unless tests pass
  • Tests have been added to verify that the new code works.

Copy link
Copy Markdown
Member

@MartinHjelmare MartinHjelmare left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good.


if not bridges:
return self.async_abort(
reason='No Philips Hue bridges discovered.'
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the style guide that we end these messages with period? Ie not the same as log messages?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. It will be shown in the UI.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will be replaced with translation keys in a future release.

def _websession(self):
"""Return a websession.

Cannot assign in init because hass variable is not set yet.
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not having access to hass and not passing it explicitly will bite us continuously in code review and as bugs, I think. But maybe there's no way around it?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we can make a default constructor

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One of the reasons I don't like constructors is that if people override it, we can never change that part anymore.

@balloob balloob merged commit 67c49a7 into dev Mar 4, 2018
@balloob balloob deleted the hue branch March 4, 2018 05:28
@balloob balloob mentioned this pull request Mar 9, 2018
@home-assistant home-assistant locked and limited conversation to collaborators Jul 26, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants